const express = require('express');
const router = express.Router();
const $common = require('../utils/common');

// 数据库
const $db = require('../db');

// 班级列表
router.get('/list', (req, res) => {
	let sql = $db.sql.class.list;
	$db.query(sql, []).then(data=>{
		res.send({
			code:200,
			msg:"操作成功",
			data:data
		});
		res.end();
	})
})

// 新增班级
router.post('/add', (req, res) => {
	let sql = $db.sql.class.add;
	let classId = 'CS' + $common.genID();
	let className = req.body.className;
	$db.query(sql, [classId,className]).then(data=>{
		res.send({
			code:200,
			msg:"操作成功"
		});
		res.end();
	})
})

module.exports = router